define([
        'backbone',       
        'views/appView',
        'views/VHeader',
        'views/VFooter',
        'views/Vcarousel',
        'views/product/VProducts'
        ],
function(
         Backbone,       
         AppView,
         VHeader,
         VFooter,
         Vcarousel,
         VProducts){
	
        var Router = Backbone.Router.extend({
		routes:{
		    '': 'index',
		    'store':'index',           
		    'search?item/:srchItem': 'loadSearchItems',
		    //'detailed-info/:productName/productId/:prodId':'fetchDetailedProductInfo'
		    'detailed-info/:prodId': 'fetchDetailedProductInfo',
            'admin':'GoToAdminPage'
		},
		index: function () {
		    console.log('APP Ver 1.0 is loading...');
		   
            var appView = new AppView();
            appView.initialPageLoad();

            //hiding filter
            appView.hideLeftPanel();
		},                        
        loadSearchItems:function(srchItem){
                       
            //setting up views or templates
            var appView = new AppView();
            appView.setPageView();

            var vProducts = new VProducts();
            //console.log(window.placeId +"-----"+srchItem);
            vProducts.searchByItem(window.placeId, srchItem)
        },
        fetchDetailedProductInfo: function (prodId) {            
            var appView = new AppView();
            appView.showProductDetailedView(prodId.split('-')[1]);
        },
        GoToAdminPage:function()
        {
            console.log('Laoding Admin Page');
            window.location.href = 'admin/admin.html'
        }
                
	});
	
    //instantiating  the Router
	var router = new Router();
	
	//it will check changes in the URL after # tag
	Backbone.history.start();
	return Router;	
});